package org.example.controller;

import org.example.BusinessExcption;
import org.example.Service.ManufactureService;
import org.example.domain.Manufacture;
import org.example.domain.User;
import org.junit.platform.commons.function.Try;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.websocket.server.PathParam;
import java.util.List;

@RestController
@RequestMapping
public class ManufactureController {

    @Autowired
    private ManufactureService manufactureService;

    @GetMapping("/queryAll")
    public List<Manufacture> queryAll() {
        List<Manufacture> manufactureList = manufactureService.queryAll();
        return manufactureList;
    }

    @GetMapping("/queryById/{id}")
    public Manufacture queryById(@PathVariable("id") Integer id) {
        return manufactureService.queryById(id);
    }

    @PostMapping("/add")
    public boolean add(@RequestBody Manufacture manufacture) {
        return manufactureService.add(manufacture);
    }

    @GetMapping("/deleteById/{id}")
    public boolean deleteById(@PathVariable("id") Integer id) {
        return manufactureService.deleteById(id);
    }

    @PostMapping("/update")
    public boolean update(@RequestBody Manufacture manufacture) {
        return manufactureService.update(manufacture);
    }




}
